package client02;

/**
 * @author cs
 * @date 2021/3/21 11:38
 */
public class Singleton5 {

    private static Singleton5 singleton;

    private Singleton5() {
    }
    public static Singleton5 getInstance() {
        if (singleton == null) {
            synchronized (Singleton5.class) {
                if (singleton == null) {
                    singleton = new Singleton5();
                }
            }
        }
        return singleton;
    }

    public static void main(String[] args) {
        Singleton5 singleton1 = Singleton5.getInstance();
        Singleton5 singleton2 = Singleton5.getInstance();
        System.out.println(singleton1==singleton2);
    }
}
